using System;
using System.Drawing;
using System.IO;
using stsdev.Builders.SourceFiles;


namespace stsdev {
  public class ImageFileBuilder {

    private static string SolutionSpecificImagesFolder = Globals.ImagesFolder + @"\" + SolutionBuilder.SolutionName;
    
    private static void EnsureImagesFolder() {
       if (!Directory.Exists(Globals.TemplatesFolder)) {
        Directory.CreateDirectory(Globals.TemplatesFolder);
      }

      if (!Directory.Exists(Globals.ImagesFolder)) {
        Directory.CreateDirectory(Globals.ImagesFolder);
      }

      if (!Directory.Exists(SolutionSpecificImagesFolder)) {
        Directory.CreateDirectory(SolutionSpecificImagesFolder);
      }
    }

    public static void Create(Bitmap Image,string ImageFileName) {
      EnsureImagesFolder();
      string ImageUrl = SolutionSpecificImagesFolder + @"\" + ImageFileName;
      Image.Save(ImageUrl);
      SolutionBuilder.SolutionProvider.ProjectProvider.AddSourceFile(new SourceFile(ImageUrl, SourceFileType.None));
    }


  }
}
